<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>
<style>
    .layui-form-label{
        width: 110px;
    }
    .layui-input-block{
        margin-left: 140px;
    }
</style>
<body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>公众号名称
                </label>
                <div class="layui-input-block">
                    <input type="text" name="name" id="name" placeholder="公众号名称" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>小程序
                </label>
                <div id="pMenu1" style="width:100%;flex:1"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>app_id
                </label>
                <div class="layui-input-block">
                    <input type="text" name="app_id" id="app_id" placeholder="app_id" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>appsecret
                </label>
                <div class="layui-input-block">
                    <input type="text" name="app_secret" id="app_secret" placeholder="appsecret" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>token
                </label>
                <div class="layui-input-block">
                    <input type="text" name="token" id="token" placeholder="token" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>原始id
                </label>
                <div class="layui-input-block">
                    <input type="text" name="original_id" id="original_id" placeholder="原始id" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>密钥
                </label>
                <div class="layui-input-block">
                    <input type="text" name="encoding_aes_key" id="encoding_aes_key" placeholder="设置的消息加密密钥EncodingAESKey" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>所属公司
                </label>
                <div id="pMenu" style="width:100%;flex:1"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>是否默认
                </label>
                <div class="layui-input-block">
                    <input type="radio" name="is_default" value="0" title="否" checked>
                    <input type="radio" name="is_default" value="1" title="是">
                </div>
            </div>

            <input type="hidden" name="id" id="id" value="" />
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />

        </form>
    </div>
    <script>
        let params = {
            addUrl:'/admin/officialAccounts/add',
            editUrl:'/admin/officialAccounts/edit',
            detailUrl: '/admin/officialAccounts/detail',
        }
        form_ajax(params)

        let selectParams = {
            url:'/admin/company/select',
            selected:[],
            tips:'选择公司',
            name: 'company_id',
            field_id:'id',
            field_Name:'name',
            elem: '#pMenu'
        }
        let selectParams1 = {
            url:'/admin/applet/select',
            selected:[],
            tips:'选择小程序',
            name: 'applet_id',
            field_id:'id',
            field_Name:'name',
            elem: '#pMenu1'
        }
        let id = GetQueryString('id')
        if(id){
            Ajax(params.detailUrl,{id}).then(result =>{
                selectParams.selected = [result.data.company_id]
                selectParams1.selected = [result.data.applet_id]
                selectN(selectParams)
                selectN(selectParams1)
            });
        }else{
            selectN(selectParams)
            selectN(selectParams1)
        }
    </script>
</body>

</html>